package com.example.springbootwebserviceproxy.proxy;

import cn.hutool.http.webservice.SoapClient;
import com.example.springbootwebserviceproxy.model.SOAPMethodBeanDefinition;
import com.example.springbootwebserviceproxy.model.WebServiceBeanDefinition;
import lombok.RequiredArgsConstructor;

/**
 * HutoolSOAPApiProxyImpl.
 *
 * @author <a href='mailto:likeguo@apache.com'> likeguo </a>
 */
@RequiredArgsConstructor
public class HutoolSOAPApiProxyImpl implements SOAPApiProxy {
    
    private final WebServiceBeanDefinition definition;
    
    @Override
    public WebServiceBeanDefinition getWebServiceBeanDefinition() {
        return definition;
    }
    
    @Override
    public Object invoke(String methodName) {
        // 新建客户端
        final SoapClient client = SoapClient.create(definition.getProxyUrl());
        final SOAPMethodBeanDefinition method = definition.getMethodMap().get(methodName);
        client.setMethod(method.getMethod(), method.getNamespace());
        
        return null;
    }
}
